package getsubs.popnapisi;

import java.io.*;
import java.net.URL;
import org.apache.commons.io.IOUtils;

public class TheRealWeb implements Web {

    private final UrlOpener urlOpener;

    public TheRealWeb(UrlOpener urlOpener) {
        this.urlOpener = urlOpener;
    }

    public String GET(String url) throws IOException {
        InputStream stream = urlOpener.openStream(url);
        try{
            return IOUtils.toString(stream, "utf-8");
        } finally {
            stream.close();
        }
    }

}
